package edu.scau.comeva.rigcontrol.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: Dan
 * Date: 13-8-15
 * Time: 下午11:20
 * To change this template use File | Settings | File Templates.
 */
@Table
@Entity
public class m_role implements Serializable {
    private long role_id;
    private String role_name;
//    private Set<m_right> role_rights;
    private Set<m_account> role_accounts;

    @Id
    @GeneratedValue
    public long getRole_id() {
        return role_id;
    }

    public void setRole_id(long role_id) {
        this.role_id = role_id;
    }

    public String getRole_name() {
        return role_name;
    }

    public void setRole_name(String role_name) {
        this.role_name = role_name;
    }

//    @ManyToMany
//    @JoinTable(
//            name = "m_role_right",
//            joinColumns = @JoinColumn(name = "fk_role_id",referencedColumnName = "role_id"),
//            inverseJoinColumns = @JoinColumn(name = "fk_right_id",referencedColumnName = "rig_id")
//    )
//    public Set<m_right> getRole_rights() {
//        return role_rights;
//    }
//
//    public void setRole_rights(Set<m_right> role_rights) {
//        this.role_rights = role_rights;
//    }

    @ManyToMany
    @JoinTable(
            name = "m_role_account",
            joinColumns = @JoinColumn(name = "fk_role_id",referencedColumnName = "role_id"),
            inverseJoinColumns = @JoinColumn(name = "fk_account_id",referencedColumnName = "acc_id")
    )
    public Set<m_account> getRole_accounts() {
        return role_accounts;
    }

    public void setRole_accounts(Set<m_account> role_accounts) {
        this.role_accounts = role_accounts;
    }
}
